<!doctype html>
<html class="no-js" lang="zh-CN">
  <head><meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width,initial-scale=1"/>
    <meta name="color-scheme" content="light dark"><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<link rel="index" title="索引" href="genindex.html" /><link rel="search" title="搜索" href="search.html" /><link rel="prev" title="Chapter 0 安装 Installation" href="chapter_0-Installation.html" />

    <!-- Generated with Sphinx 5.3.0 and Furo 2023.03.27 -->
        <title>Chapter 1 启航 Getting Started - 聪明办法学 Python</title>
      <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=fad236701ea90a88636c2a8c73b44ae642ed2a53" />
    <link rel="stylesheet" type="text/css" href="_static/mystnb.4510f1fc1dee50b3e5859aac5469c37c29e427902b24a333a5f9fcb2f0b3ac41.css" />
    <link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
    <link rel="stylesheet" type="text/css" href="_static/togglebutton.css" />
    <link rel="stylesheet" type="text/css" href="_static/design-style.1e8bd061cd6da7fc9cf755528e8ffc24.min.css" />
    <link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?digest=30d1aed668e5c3a91c3e3bf6a60b675221979f0e" />
    
    


<style>
  body {
    --color-code-background: #f8f8f8;
  --color-code-foreground: black;
  
  }
  @media not print {
    body[data-theme="dark"] {
      --color-code-background: #202020;
  --color-code-foreground: #d0d0d0;
  
    }
    @media (prefers-color-scheme: dark) {
      body:not([data-theme="light"]) {
        --color-code-background: #202020;
  --color-code-foreground: #d0d0d0;
  
      }
    }
  }
</style></head>
  <body>
    
    <script>
      document.body.dataset.theme = localStorage.getItem("theme") || "auto";
    </script>
    

<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  <symbol id="svg-toc" viewBox="0 0 24 24">
    <title>Contents</title>
    <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024">
      <path d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 0 0 0 13.8z"/>
    </svg>
  </symbol>
  <symbol id="svg-menu" viewBox="0 0 24 24">
    <title>Menu</title>
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
      stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-menu">
      <line x1="3" y1="12" x2="21" y2="12"></line>
      <line x1="3" y1="6" x2="21" y2="6"></line>
      <line x1="3" y1="18" x2="21" y2="18"></line>
    </svg>
  </symbol>
  <symbol id="svg-arrow-right" viewBox="0 0 24 24">
    <title>Expand</title>
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
      stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-chevron-right">
      <polyline points="9 18 15 12 9 6"></polyline>
    </svg>
  </symbol>
  <symbol id="svg-sun" viewBox="0 0 24 24">
    <title>Light mode</title>
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
      stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather-sun">
      <circle cx="12" cy="12" r="5"></circle>
      <line x1="12" y1="1" x2="12" y2="3"></line>
      <line x1="12" y1="21" x2="12" y2="23"></line>
      <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
      <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
      <line x1="1" y1="12" x2="3" y2="12"></line>
      <line x1="21" y1="12" x2="23" y2="12"></line>
      <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
      <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
    </svg>
  </symbol>
  <symbol id="svg-moon" viewBox="0 0 24 24">
    <title>Dark mode</title>
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
      stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-moon">
      <path stroke="none" d="M0 0h24v24H0z" fill="none" />
      <path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" />
    </svg>
  </symbol>
  <symbol id="svg-sun-half" viewBox="0 0 24 24">
    <title>Auto light/dark mode</title>
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
      stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-shadow">
      <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
      <circle cx="12" cy="12" r="9" />
      <path d="M13 12h5" />
      <path d="M13 15h4" />
      <path d="M13 18h1" />
      <path d="M13 9h4" />
      <path d="M13 6h1" />
    </svg>
  </symbol>
</svg>

<input type="checkbox" class="sidebar-toggle" name="__navigation" id="__navigation">
<input type="checkbox" class="sidebar-toggle" name="__toc" id="__toc">
<label class="overlay sidebar-overlay" for="__navigation">
  <div class="visually-hidden">Hide navigation sidebar</div>
</label>
<label class="overlay toc-overlay" for="__toc">
  <div class="visually-hidden">Hide table of contents sidebar</div>
</label>

<div class="announcement">
  <aside class="announcement-content">
     聪明办法学 Python 在线文档 Beta 测试 
  </aside>
</div>

<div class="page">
  <header class="mobile-header">
    <div class="header-left">
      <label class="nav-overlay-icon" for="__navigation">
        <div class="visually-hidden">Toggle site navigation sidebar</div>
        <i class="icon"><svg><use href="#svg-menu"></use></svg></i>
      </label>
    </div>
    <div class="header-center">
      <a href="index.html"><div class="brand"><div align=center><small>聪明办法学 Python</small></div></div></a>
    </div>
    <div class="header-right">
      <div class="theme-toggle-container theme-toggle-header">
        <button class="theme-toggle">
          <div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
          <svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
          <svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
          <svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
        </button>
      </div>
      <label class="toc-overlay-icon toc-header-icon" for="__toc">
        <div class="visually-hidden">Toggle table of contents sidebar</div>
        <i class="icon"><svg><use href="#svg-toc"></use></svg></i>
      </label>
    </div>
  </header>
  <aside class="sidebar-drawer">
    <div class="sidebar-container">
      
      <div class="sidebar-sticky"><a class="sidebar-brand centered" href="index.html">
  
  <div class="sidebar-logo-container">
    <img class="sidebar-logo" src="_static/datawhale_logo.png" alt="Logo"/>
  </div>
  
  <span class="sidebar-brand-text"><div align=center><small>聪明办法学 Python</small></div></span>
  
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
  <input class="sidebar-search" placeholder="搜索" name="q" aria-label="搜索">
  <input type="hidden" name="check_keywords" value="yes">
  <input type="hidden" name="area" value="default">
</form>
<div id="searchbox"></div><div class="sidebar-scroll"><div class="sidebar-tree">
  <p class="caption" role="heading"><span class="caption-text">目录</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="chapter_0-Installation.html">Chapter 0 安装 Installation</a></li>
</ul>
<ul class="current">
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Chapter 1 启航 Getting Started</a></li>
</ul>

</div>
</div>

      </div>
      
    </div>
  </aside>
  <div class="main">
    <div class="content">
      <div class="article-container">
        <a href="#" class="back-to-top muted-link">
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
            <path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"></path>
          </svg>
          <span>Back to top</span>
        </a>
        <div class="content-icon-container">
          <div class="edit-this-page">
  <a class="muted-link" href="https://github.com/anine09/p2s-book/edit/main/docs/chapter_1-Getting_Started.ipynb" title="Edit this page">
    <svg aria-hidden="true" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
      <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
      <path d="M4 20h4l10.5 -10.5a1.5 1.5 0 0 0 -4 -4l-10.5 10.5v4" />
      <line x1="13.5" y1="6.5" x2="17.5" y2="10.5" />
    </svg>
    <span class="visually-hidden">Edit this page</span>
  </a>
</div><div class="theme-toggle-container theme-toggle-content">
            <button class="theme-toggle">
              <div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
              <svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
              <svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
              <svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
            </button>
          </div>
          <label class="toc-overlay-icon toc-content-icon" for="__toc">
            <div class="visually-hidden">Toggle table of contents sidebar</div>
            <i class="icon"><svg><use href="#svg-toc"></use></svg></i>
          </label>
        </div>
        <article role="main">
          <section class="tex2jax_ignore mathjax_ignore" id="chapter-1-getting-started">
<h1>Chapter 1 启航 Getting Started<a class="headerlink" href="#chapter-1-getting-started" title="此标题的永久链接">#</a></h1>
<section id="p2s">
<h2>欢迎大家来到 P2S！<a class="headerlink" href="#p2s" title="此标题的永久链接">#</a></h2>
<p>迈出成为 AI 训练大师的第一步！</p>
<p><img alt="AI Master" src="_images/AIMaster.jpg" /></p>
</section>
<section id="id1">
<h2>第一行代码<a class="headerlink" href="#id1" title="此标题的永久链接">#</a></h2>
<p>Language C</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span><span class="cpf">&lt;stdio.h&gt;</span><span class="c1"> </span>
<span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="p">(){</span>
<span class="w">    </span><span class="n">printf</span><span class="p">(</span><span class="s">&quot;Hello, World&quot;</span><span class="p">);</span>
<span class="w">    </span><span class="k">return</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;聪明办法学Python&quot;</span><span class="p">)</span> 
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>聪明办法学Python
</pre></div>
</div>
</div>
</div>
</section>
<section id="hello-world">
<h2>Hello World 的由来<a class="headerlink" href="#hello-world" title="此标题的永久链接">#</a></h2>
<p><img alt="Brian Kernighan" src="_images/464px-Brian-Kernighan-2017.png" /></p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">main</span><span class="p">(</span><span class="w"> </span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="n">printf</span><span class="p">(</span><span class="s">&quot;hello, word&quot;</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Brian Wilson Kernighan, 1972</p>
<p><em>A Tutorial Introduction to the Language B</em></p>
<p>Language B Version:</p>
<div class="highlight-B notranslate"><div class="highlight"><pre><span></span>main( ) {
    extern a, b, c;
    putchar(a); putchar(b); putchar(c); putchar(&#39;!*n&#39;);
}
 
a &#39;hell&#39;;
b &#39;o, w&#39;;
c &#39;orld&#39;;
</pre></div>
</div>
</section>
<section id="comment">
<h2>注释 Comment<a class="headerlink" href="#comment" title="此标题的永久链接">#</a></h2>
<p>分类：</p>
<ul class="simple">
<li><p>单行注释，使用 <code class="docutils literal notranslate"><span class="pre">#</span></code> 开头</p></li>
<li><p>多行注释，使用 <code class="docutils literal notranslate"><span class="pre">'''</span></code> 或 <code class="docutils literal notranslate"><span class="pre">&quot;&quot;&quot;</span></code> 包裹起来</p></li>
</ul>
<p>作用：</p>
<ul class="simple">
<li><p>注释主要是用于对代码进行<strong>解释和说明</strong>，可以提升代码的可读性</p></li>
<li><p>注释并<strong>不会被当做代码处理</strong> # magic comment 除外</p></li>
</ul>
<blockquote>
<div><p>程序员最讨厌的 10 件事：0. 别人的代码不写注释。 1. 给自己的代码写注释</p>
</div></blockquote>
<blockquote>
<div><p>当初写这段代码的时候只有上帝和我知道它是干嘛的，现在只有上帝知道</p>
</div></blockquote>
<p><big>单行注释</big></p>
<p>使用 <code class="docutils literal notranslate"><span class="pre">#</span></code> 开头，<code class="docutils literal notranslate"><span class="pre">#</span></code> 后面的内容不会被当做代码，只能写在一行中</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Datawhale&quot;</span><span class="p">)</span> <span class="c1"># for the learner，和学习者一起成长</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Datawhale
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="c1"># learn python the smart way v2</span>
<span class="linenos">2</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;p2s&quot;</span><span class="p">)</span>
<span class="linenos">3</span><span class="c1"># print(&quot;prepare to be smart&quot;)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>p2s
</pre></div>
</div>
</div>
</div>
<p><big>多行注释</big></p>
<p>使用 <code class="docutils literal notranslate"><span class="pre">'''</span></code> 或 <code class="docutils literal notranslate"><span class="pre">&quot;&quot;&quot;</span></code> 包裹起来(头和尾都是 3 个)，<strong>单引号（’）与双引号（”）在 Python 中并无太大区别</strong></p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;人生苦短，我用 Python&quot;</span><span class="p">)</span>
<span class="linenos">2</span><span class="sd">&#39;&#39;&#39;</span>
<span class="linenos">3</span><span class="sd">Python is powerful... and fast;</span>
<span class="linenos">4</span><span class="sd">plays well with others;</span>
<span class="linenos">5</span><span class="sd">runs everywhere;</span>
<span class="linenos">6</span><span class="sd">is friendly &amp; easy to learn;</span>
<span class="linenos">7</span><span class="sd">is Open.</span>
<span class="linenos">8</span><span class="sd">&#39;&#39;&#39;</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>人生苦短，我用 Python
</pre></div>
</div>
</div>
</div>
</section>
<section id="basic-console-output">
<h2>基础的控制台输出 Basic Console Output<a class="headerlink" href="#basic-console-output" title="此标题的永久链接">#</a></h2>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Datawhale&quot;</span><span class="p">)</span> <span class="c1"># for the learner，和学习者一起成长</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Datawhale
</pre></div>
</div>
</div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">print()</span></code> 的作用是将填入的内容显示在 Console 中，默认每次输入后会换行（等价于按了一次回车，或者 <code class="docutils literal notranslate"><span class="pre">\n</span></code>）</p>
<p>控制结尾的参数是 <code class="docutils literal notranslate"><span class="pre">end</span></code></p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Data&quot;</span><span class="p">)</span>
<span class="linenos">2</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;whale&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Data
whale
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Data&quot;</span><span class="p">,</span> <span class="n">end</span><span class="o">=</span><span class="s2">&quot;*&quot;</span><span class="p">)</span>
<span class="linenos">2</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;whale&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Data*whale
</pre></div>
</div>
</div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">print()</span></code> 一次也可以输出多个内容，默认以空格分隔</p>
<p>控制分隔的参数是 <code class="docutils literal notranslate"><span class="pre">sep</span></code></p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Data&quot;</span><span class="p">,</span><span class="s2">&quot;whale&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Data whale
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Data&quot;</span><span class="p">,</span> <span class="s2">&quot;whale&quot;</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">&quot;*&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Data*whale
</pre></div>
</div>
</div>
</div>
<p>你甚至可以做<strong>加法</strong>和<strong>乘法</strong>！</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;p2s&quot;</span><span class="o">*</span><span class="mi">2</span><span class="p">,</span><span class="s2">&quot;data&quot;</span><span class="o">*</span><span class="mi">3</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">&quot;/&quot;</span><span class="o">*</span><span class="mi">4</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>p2sp2s////datadatadata
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Data&quot;</span><span class="o">+</span><span class="s2">&quot;whale&quot;</span><span class="o">+</span><span class="s2">&quot;P2S&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>DatawhaleP2S
</pre></div>
</div>
</div>
</div>
<section id="id2">
<h3>一些更好玩的做法<a class="headerlink" href="#id2" title="此标题的永久链接">#</a></h3>
<p>我们假设，</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="n">x</span> <span class="o">=</span> <span class="mi">1</span>
<span class="linenos">2</span><span class="n">y</span> <span class="o">=</span> <span class="mi">2</span>
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;一个简单的数学问题：</span><span class="se">\&quot;</span><span class="si">{</span><span class="n">x</span><span class="si">}</span><span class="s2"> + </span><span class="si">{</span><span class="n">y</span><span class="si">}</span><span class="s2"> = ?</span><span class="se">\&quot;</span><span class="s2">，答案是 </span><span class="si">{</span><span class="n">x</span><span class="o">+</span><span class="n">y</span><span class="si">}</span><span class="s2">！&quot;</span><span class="p">)</span> <span class="c1"># f-strings</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>一个简单的数学问题：&quot;1 + 2 = ?&quot;，答案是 3！
</pre></div>
</div>
</div>
</div>
<p>为了课程演示，我们编写了下面这些代码，你并不需要弄清楚它具体内容是什么，享受游戏的过程就好了 ;-)</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="kn">from</span> <span class="nn">ipywidgets</span> <span class="kn">import</span> <span class="n">interact</span>
<span class="linenos">2</span><span class="k">def</span> <span class="nf">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
<span class="linenos">3</span>    <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;A simple math question: </span><span class="se">\&quot;</span><span class="si">{</span><span class="n">x</span><span class="si">}</span><span class="s2"> + </span><span class="si">{</span><span class="n">y</span><span class="si">}</span><span class="s2"> = ?</span><span class="se">\&quot;</span><span class="s2">, the answer is </span><span class="si">{</span><span class="n">x</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">y</span><span class="si">}</span><span class="s2">!&quot;</span><span class="p">)</span>
<span class="linenos">4</span><span class="n">interact</span><span class="p">(</span><span class="n">f</span><span class="p">,</span><span class="n">x</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<script type="application/vnd.jupyter.widget-view+json">{"model_id": "269dca0cf8894f06b23ebf3a0cdb85a0", "version_major": 2, "version_minor": 0}</script><div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;function __main__.f(x, y)&gt;
</pre></div>
</div>
</div>
</div>
<p>如果我想<strong>一次性输出很多行</strong>？</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;&quot;</span>
<span class="linenos">2</span><span class="s2">Python is powerful... and fast;</span>
<span class="linenos">3</span><span class="s2">plays well with others;</span>
<span class="linenos">4</span><span class="s2">runs everywhere;</span>
<span class="linenos">5</span><span class="s2">is friendly &amp; easy to learn;</span>
<span class="linenos">6</span><span class="s2">is Open.</span>
<span class="linenos">7</span><span class="s2">&quot;&quot;&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Python is powerful... and fast;
plays well with others;
runs everywhere;
is friendly &amp; easy to learn;
is Open.
</pre></div>
</div>
</div>
</div>
</section>
</section>
<section id="id3">
<h2>如何秒杀马里奥题<a class="headerlink" href="#id3" title="此标题的永久链接">#</a></h2>
<p><a class="reference external" href="https://www.luogu.com.cn/problem/P1000">洛谷 P1000 超级玛丽游戏</a></p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="kn">from</span> <span class="nn">IPython.display</span> <span class="kn">import</span> <span class="n">IFrame</span>
<span class="linenos">2</span><span class="n">IFrame</span><span class="p">(</span><span class="s1">&#39;https://www.luogu.com.cn/problem/P1000&#39;</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="s2">&quot;100%&quot;</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mi">600</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html">
        <iframe
            width="100%"
            height="600"
            src="https://www.luogu.com.cn/problem/P1000"
            frameborder="0"
            allowfullscreen
            
        ></iframe>
        </div></div>
</div>
</section>
<section id="error">
<h2>错误 Error<a class="headerlink" href="#error" title="此标题的永久链接">#</a></h2>
<ul class="simple">
<li><p>语法错误 Syntax Errors，不符合语法规范，代码根本<strong>没有开始运行</strong></p></li>
<li><p>“运行时”错误 Runtime Errors，代码在<strong>运行过程中出错</strong>，也就是常说的“崩溃”（Crash）</p></li>
<li><p>逻辑错误 Logical Errors，代码能够运行，且运行过程中没有出错，但是<strong>不是想要的结果</strong></p></li>
</ul>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="c1"># 语法错误（在编译时出错，Python 并没有开始运行代码）</span>
<span class="linenos">2</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;哦不！) # Error! 缺少结尾引号</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span>  <span class="n">Cell</span> <span class="n">In</span><span class="p">[</span><span class="mi">6</span><span class="p">],</span> <span class="n">line</span> <span class="mi">2</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;哦不！) # Error! 缺少结尾引号</span>
          <span class="o">^</span>
<span class="ne">SyntaxError</span>: unterminated string literal (detected at line 2)
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="c1"># “运行时”错误（Python 开始运行代码，但是遇到了些问题）</span>
<span class="linenos">2</span><span class="nb">print</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># Error! 0 被作为除数</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span><span class="gt">---------------------------------------------------------------------------</span>
<span class="ne">ZeroDivisionError</span><span class="g g-Whitespace">                         </span>Traceback (most recent call last)
<span class="n">Cell</span> <span class="n">In</span><span class="p">[</span><span class="mi">7</span><span class="p">],</span> <span class="n">line</span> <span class="mi">2</span>
<span class="g g-Whitespace">      </span><span class="mi">1</span> <span class="c1"># “运行时”错误（Python 开始运行代码，但是遇到了些问题）</span>
<span class="ne">----&gt; </span><span class="mi">2</span> <span class="nb">print</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># Error! 0 被作为除数</span>

<span class="ne">ZeroDivisionError</span>: division by zero
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="c1"># Logical Errors (Compiles and runs, but is wrong!)</span>
<span class="linenos">2</span><span class="c1"># 逻辑错误（能编译，能运行，但不是想要的结果）</span>
<span class="linenos">3</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;2+2=5&quot;</span><span class="p">)</span> <span class="c1"># Error! 算错了！！！</span>
<span class="linenos">4</span><span class="c1"># 我们想要：4！</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2+2=5
</pre></div>
</div>
</div>
</div>
</section>
<section id="basic-console-input">
<h2>基础的控制台输入 Basic Console Input<a class="headerlink" href="#basic-console-input" title="此标题的永久链接">#</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">input()</span></code> 可以接收 Console 的输入，并<strong>以字符串的形式返回</strong>，你可以给定个字符串参数，它会先输出到 Console，再接收输入</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="n">name</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s2">&quot;输入你的名字：&quot;</span><span class="p">)</span>
<span class="linenos">2</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;あなたの名前は&quot;</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="s2">&quot;です&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>输入你的名字：Datawhale
あなたの名前は Datawhale です
</pre></div>
</div>
</div>
</div>
</section>
<section id="id4">
<h2>注意！返回的格式是字符串<a class="headerlink" href="#id4" title="此标题的永久链接">#</a></h2>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="n">x</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s2">&quot;输入一个数字: &quot;</span><span class="p">)</span>
<span class="linenos">2</span><span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="s2">&quot;的一半等于&quot;</span><span class="p">,</span> <span class="n">x</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span> <span class="c1"># Error!</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>输入一个数字: 10
</pre></div>
</div>
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span><span class="gt">---------------------------------------------------------------------------</span>
<span class="ne">TypeError</span><span class="g g-Whitespace">                                 </span>Traceback (most recent call last)
<span class="n">Cell</span> <span class="n">In</span><span class="p">[</span><span class="mi">9</span><span class="p">],</span> <span class="n">line</span> <span class="mi">2</span>
<span class="g g-Whitespace">      </span><span class="mi">1</span> <span class="n">x</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s2">&quot;输入一个数字: &quot;</span><span class="p">)</span>
<span class="ne">----&gt; </span><span class="mi">2</span> <span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="s2">&quot;的一半等于&quot;</span><span class="p">,</span> <span class="n">x</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span> <span class="c1"># Error!</span>

<span class="ne">TypeError</span>: unsupported operand type(s) for /: &#39;str&#39; and &#39;int&#39;
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="n">x</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s2">&quot;输入一个数字: &quot;</span><span class="p">)</span>
<span class="linenos">2</span><span class="n">x</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="c1"># 类型转换 float(x)</span>
<span class="linenos">3</span><span class="c1"># x = int(input(&quot;输入一个数字：&quot;))</span>
<span class="linenos">4</span><span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="s2">&quot;的一半等于&quot;</span><span class="p">,</span> <span class="n">x</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span> <span class="c1"># 对味啦</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>输入一个数字: 10
10 的一半等于 5.0
</pre></div>
</div>
</div>
</div>
<section id="id5">
<h3>一行多个输入值<a class="headerlink" href="#id5" title="此标题的永久链接">#</a></h3>
<p>1 -&gt; a，2 -&gt; b</p>
<p>可以在结尾加上 <code class="docutils literal notranslate"><span class="pre">split()</span></code>，默认分隔参数是空格，可以更改，如：<code class="docutils literal notranslate"><span class="pre">split(&quot;,&quot;)</span></code></p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span> <span class="o">=</span> <span class="nb">input</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
<span class="linenos">2</span><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;a = </span><span class="si">{</span><span class="n">a</span><span class="si">}</span><span class="s2">, b = </span><span class="si">{</span><span class="n">b</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>1 2
a = 1, b = 2
</pre></div>
</div>
</div>
</div>
</section>
</section>
<section id="id6">
<h2>导入模块<a class="headerlink" href="#id6" title="此标题的永久链接">#</a></h2>
<p>Python 中有许多强大的工具箱，我们把它们叫做**“库”（Library）**，课程后期会介绍更多强大的工具</p>
<p>库需要使用 <code class="docutils literal notranslate"><span class="pre">import</span></code> 来导入，并且使用 <code class="docutils literal notranslate"><span class="pre">xx.yy</span></code>的方式来调用，我们今天只作粗略介绍</p>
<p>以 Python 内置数学库 <code class="docutils literal notranslate"><span class="pre">math</span></code> 为例：</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="c1"># 阶乘 factorial</span>
<span class="linenos">2</span><span class="nb">print</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">factorial</span><span class="p">(</span><span class="mi">20</span><span class="p">))</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span><span class="gt">---------------------------------------------------------------------------</span>
<span class="ne">NameError</span><span class="g g-Whitespace">                                 </span>Traceback (most recent call last)
<span class="n">Cell</span> <span class="n">In</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">line</span> <span class="mi">2</span>
<span class="g g-Whitespace">      </span><span class="mi">1</span> <span class="c1"># 阶乘 factorial</span>
<span class="ne">----&gt; </span><span class="mi">2</span> <span class="nb">print</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">factorial</span><span class="p">(</span><span class="mi">20</span><span class="p">))</span>

<span class="ne">NameError</span>: name &#39;math&#39; is not defined
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="kn">import</span> <span class="nn">math</span> <span class="c1"># 使用库前要先导入！</span>
<span class="linenos">2</span><span class="nb">print</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">factorial</span><span class="p">(</span><span class="mi">3</span><span class="p">))</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>6
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="c1"># Euler 常数</span>
<span class="linenos">2</span><span class="nb">print</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">e</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="c1"># gcd 最大公约数</span>
<span class="linenos">2</span><span class="n">math</span><span class="o">.</span><span class="n">gcd</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mi">36</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="k">def</span> <span class="nf">f</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
<span class="linenos">2</span>    <span class="n">a</span> <span class="o">=</span> <span class="n">x</span><span class="o">*</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">pi</span><span class="o">/</span><span class="mi">180</span><span class="p">)</span>
<span class="linenos">3</span>    <span class="nb">print</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="n">a</span><span class="p">))</span>
<span class="linenos">4</span><span class="n">interact</span><span class="p">(</span><span class="n">f</span><span class="p">,</span><span class="n">x</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<script type="application/vnd.jupyter.widget-view+json">{"model_id": "e4ba700850414beeae5cc9e46380bd95", "version_major": 2, "version_minor": 0}</script><div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;function __main__.f(x)&gt;
</pre></div>
</div>
</div>
</div>
</section>
<section id="id7">
<h2>补充资料<a class="headerlink" href="#id7" title="此标题的永久链接">#</a></h2>
<p>0.1+0.2≠0.3?? 无可避免的浮点误差：<a class="reference external" href="https://www.bilibili.com/video/BV1xq4y1D7Ep">https://www.bilibili.com/video/BV1xq4y1D7Ep</a></p>
<iframe src="//player.bilibili.com/player.html?aid=590031661&bvid=BV1xq4y1D7Ep&cid=396310990&p=1danmaku=0&autoplay=0&hideDanmakuButton=1" allowfullscreen="allowfullscreen" width="100%" height="500" scrolling="no" frameborder="0" sandbox="allow-top-navigation allow-same-origin allow-forms allow-scripts"></iframe></section>
<section id="id8">
<h2>总结<a class="headerlink" href="#id8" title="此标题的永久链接">#</a></h2>
<ul class="simple">
<li><p>写注释是个好习惯</p></li>
<li><p>调整输入输出的参数来控制其呈现效果</p></li>
<li><p>大部分错误类型可以归为：语法错误、运行时错误和逻辑错误</p></li>
<li><p>Python 的库能让很多操作变方便</p></li>
</ul>
</section>
</section>

        </article>
      </div>
      <footer>
        
        <div class="related-pages">
          
          <a class="prev-page" href="chapter_0-Installation.html">
              <svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
              <div class="page-info">
                <div class="context">
                  <span>Previous</span>
                </div>
                
                <div class="title">Chapter 0 安装 Installation</div>
                
              </div>
            </a>
        </div>
        <div class="bottom-of-page">
          <div class="left-details">
            <div class="copyright">
                Copyright &#169; 2022 - 2023 Datawhale P2S Team
            </div>
            Made with <a href="https://www.sphinx-doc.org/">Sphinx</a> and <a class="muted-link" href="https://pradyunsg.me">@pradyunsg</a>'s
            
            <a href="https://github.com/pradyunsg/furo">Furo</a>
            
          </div>
          <div class="right-details">
            
          </div>
        </div>
        
      </footer>
    </div>
    <aside class="toc-drawer">
      
      
      <div class="toc-sticky toc-scroll">
        <div class="toc-title-container">
          <span class="toc-title">
            On this page
          </span>
        </div>
        <div class="toc-tree-container">
          <div class="toc-tree">
            <ul>
<li><a class="reference internal" href="#">Chapter 1 启航 Getting Started</a><ul>
<li><a class="reference internal" href="#p2s">欢迎大家来到 P2S！</a></li>
<li><a class="reference internal" href="#id1">第一行代码</a></li>
<li><a class="reference internal" href="#hello-world">Hello World 的由来</a></li>
<li><a class="reference internal" href="#comment">注释 Comment</a></li>
<li><a class="reference internal" href="#basic-console-output">基础的控制台输出 Basic Console Output</a><ul>
<li><a class="reference internal" href="#id2">一些更好玩的做法</a></li>
</ul>
</li>
<li><a class="reference internal" href="#id3">如何秒杀马里奥题</a></li>
<li><a class="reference internal" href="#error">错误 Error</a></li>
<li><a class="reference internal" href="#basic-console-input">基础的控制台输入 Basic Console Input</a></li>
<li><a class="reference internal" href="#id4">注意！返回的格式是字符串</a><ul>
<li><a class="reference internal" href="#id5">一行多个输入值</a></li>
</ul>
</li>
<li><a class="reference internal" href="#id6">导入模块</a></li>
<li><a class="reference internal" href="#id7">补充资料</a></li>
<li><a class="reference internal" href="#id8">总结</a></li>
</ul>
</li>
</ul>

          </div>
        </div>
      </div>
      
      
    </aside>
  </div>
</div><script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/sphinx_highlight.js"></script>
    <script src="_static/scripts/furo.js"></script>
    <script src="_static/clipboard.min.js"></script>
    <script src="_static/copybutton.js"></script>
    <script>let toggleHintShow = 'Click to show';</script>
    <script>let toggleHintHide = 'Click to hide';</script>
    <script>let toggleOpenOnPrint = 'true';</script>
    <script src="_static/togglebutton.js"></script>
    <script src="_static/translations.js"></script>
    <script src="_static/design-tabs.js"></script>
    <script>var togglebuttonSelector = '.toggle, .admonition.dropdown';</script>
    <script type="application/vnd.jupyter.widget-state+json">{"state": {"003e2839405643178ad12e3f7dcf80a7": {"model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": {"layout": "IPY_MODEL_81e59674f08446e5b134291b7ae87207", "outputs": [{"name": "stdout", "output_type": "stream", "text": "0.49999999999999994\n"}]}}, "018a4034db1740078a28b8657b564ee9": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "y", "layout": "IPY_MODEL_81117538a7204835af525956b6952657", "max": 60, "min": -20, "style": "IPY_MODEL_7f27186ea90b4363ba8da4c634fad959", "value": 20}}, "044d5538d41940ab9acd4ef27b5738ac": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "y", "layout": "IPY_MODEL_05e0910f4e2140738dff3770f09e9222", "max": 60, "min": -20, "style": "IPY_MODEL_06339b6d09b447ee90676a6468d01266", "value": 20}}, "05e0910f4e2140738dff3770f09e9222": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "06339b6d09b447ee90676a6468d01266": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "06597f52cd07407e84da8c413e830790": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "VBoxModel", "state": {"_dom_classes": ["widget-interact"], "children": ["IPY_MODEL_2b7b8c5874ce45c5a91ad81e8ff676b8", "IPY_MODEL_36e658d568eb4f7e95e86585379006b6", "IPY_MODEL_6e21045934b347c3811088107f6d68eb"], "layout": "IPY_MODEL_3d088011a8164153ade0eda07733a6d8"}}, "0669fc56ae8b408e921beba3520f6d14": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "08706438180f435da3bb6764b59ab88f": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "1029279f289a4c81bcf47c59bc2272c0": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "124c0a2197ad4d01a66a3510523d6bab": {"model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": {"layout": "IPY_MODEL_a540171b24ce4763b108471cb1020a82", "outputs": [{"name": "stdout", "output_type": "stream", "text": "A simple math question: \"10 + 20 = ?\", the answer is 30!\n"}]}}, "141e098668fe4416ab5cbee6d09464d5": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "146ec45be8cb4288ab2a261a3bdc90cd": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "19b830f2dbd042e49e2cc475f730e733": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "x", "layout": "IPY_MODEL_92c7ee7359014d4e84ab0eb3847896b7", "max": 90, "min": -30, "style": "IPY_MODEL_aca0df7dd525439da4fbb3c85ec74a2f", "value": 30}}, "1e65cb9cf136405db061cd4ec5281068": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "213b6906ace74617a0a7c37f7fe80e33": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "269dca0cf8894f06b23ebf3a0cdb85a0": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "VBoxModel", "state": {"_dom_classes": ["widget-interact"], "children": ["IPY_MODEL_e612fa032644456599e7c058fe83441c", "IPY_MODEL_36a8013c542a4331a7f6ebe43e7c24b9", "IPY_MODEL_e7e8154648c04623b0ddece5ab4c19c4"], "layout": "IPY_MODEL_52e35c053286418d9fe5ada68a6c9a52"}}, "2727ceebd04c4d3ab4db4e2dbfc64fa7": {"model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": {"layout": "IPY_MODEL_c1224ebc63a94fc0bf02592c6de76673", "outputs": [{"ename": "NameError", "evalue": "name 'math' is not defined", "output_type": "error", "traceback": ["\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)", "File \u001b[1;32m~\\miniconda3\\envs\\p2s\\Lib\\site-packages\\ipywidgets\\widgets\\interaction.py:240\u001b[0m, in \u001b[0;36minteractive.update\u001b[1;34m(self, *args)\u001b[0m\n\u001b[0;32m    238\u001b[0m     value \u001b[38;5;241m=\u001b[39m widget\u001b[38;5;241m.\u001b[39mget_interact_value()\n\u001b[0;32m    239\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mkwargs[widget\u001b[38;5;241m.\u001b[39m_kwarg] \u001b[38;5;241m=\u001b[39m value\n\u001b[1;32m--> 240\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mresult \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mf\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    241\u001b[0m show_inline_matplotlib_plots()\n\u001b[0;32m    242\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mauto_display \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mresult \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n", "Cell \u001b[1;32mIn[4], line 2\u001b[0m, in \u001b[0;36mf\u001b[1;34m(x)\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mf\u001b[39m(x):\n\u001b[1;32m----> 2\u001b[0m     a \u001b[38;5;241m=\u001b[39m x\u001b[38;5;241m*\u001b[39m(\u001b[43mmath\u001b[49m\u001b[38;5;241m.\u001b[39mpi\u001b[38;5;241m/\u001b[39m\u001b[38;5;241m180\u001b[39m)\n\u001b[0;32m      3\u001b[0m     \u001b[38;5;28mprint\u001b[39m(math\u001b[38;5;241m.\u001b[39msin(a))\n", "\u001b[1;31mNameError\u001b[0m: name 'math' is not defined"]}]}}, "2b763158a5e74331b3cc64f730e12ada": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "2b7b8c5874ce45c5a91ad81e8ff676b8": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "x", "layout": "IPY_MODEL_b0a8761742ad411994f4968b110a7c5c", "max": 30, "min": -10, "style": "IPY_MODEL_30074bf89bae455899db34859ee5dec4", "value": 10}}, "2edda18376d24e9f9a385cbfaede7ffe": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "x", "layout": "IPY_MODEL_1e65cb9cf136405db061cd4ec5281068", "max": 90, "min": -30, "style": "IPY_MODEL_88bc243b5c4d457f9a88ab47a92adfc0", "value": 30}}, "30074bf89bae455899db34859ee5dec4": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "30c6c6a8026a475fa022433c08b69516": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "36a8013c542a4331a7f6ebe43e7c24b9": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "y", "layout": "IPY_MODEL_993be00b43bf4685ae6fd529f78c437f", "max": 60, "min": -20, "style": "IPY_MODEL_4ea5c43e0f3e442aa8afe850ab2f4ce2", "value": 20}}, "36e658d568eb4f7e95e86585379006b6": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "y", "layout": "IPY_MODEL_85aa9195bd6f402ab20f7999aba1c02f", "max": 60, "min": -20, "style": "IPY_MODEL_6b716bc3263f47d8a21bb7f2b5c35620", "value": 20}}, "3701e13c50e640929bde5fc742abc50a": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "VBoxModel", "state": {"_dom_classes": ["widget-interact"], "children": ["IPY_MODEL_f547b163776f400f88246dd3034af06d", "IPY_MODEL_003e2839405643178ad12e3f7dcf80a7"], "layout": "IPY_MODEL_7599cb8f58d2491f804cdc405d3b3de0"}}, "3d088011a8164153ade0eda07733a6d8": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "44f20e4143974f4a98677aef404da584": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "y", "layout": "IPY_MODEL_b14b5a1e63b14da8ac763e094cfbe97d", "max": 60, "min": -20, "style": "IPY_MODEL_146ec45be8cb4288ab2a261a3bdc90cd", "value": 20}}, "4c93be31d4f64faf9f731ec379484394": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "VBoxModel", "state": {"_dom_classes": ["widget-interact"], "children": ["IPY_MODEL_a84e9e66a9de401783a2a41d817fbc73", "IPY_MODEL_018a4034db1740078a28b8657b564ee9", "IPY_MODEL_e7bc41997974427d8f95d8f330e99fd6"], "layout": "IPY_MODEL_e66005c43b3f46a0b009c97bf618e598"}}, "4ea5c43e0f3e442aa8afe850ab2f4ce2": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "523f2d75879a44db95663bb6436dd05d": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "52bc603adc694f558a39258ec1e76156": {"model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": {"layout": "IPY_MODEL_f2870f8d10d34b3f96d42559e9daa2bb", "outputs": [{"name": "stdout", "output_type": "stream", "text": "A simple math question: \"10 + 20 = ?\", the answer is 30!\n"}]}}, "52e35c053286418d9fe5ada68a6c9a52": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "5fa97c4bec854976bea24b77f24070c7": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "VBoxModel", "state": {"_dom_classes": ["widget-interact"], "children": ["IPY_MODEL_81c927ff342f4a4cba245c79187c61e9", "IPY_MODEL_044d5538d41940ab9acd4ef27b5738ac", "IPY_MODEL_124c0a2197ad4d01a66a3510523d6bab"], "layout": "IPY_MODEL_889c5c66d5814484beb27a66b0174c0c"}}, "60844ca57adf403dbd6b4cd4b8578e15": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "624dfe9850d144ad9468b136f81836ac": {"model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": {"layout": "IPY_MODEL_9e1f9f69004e4eb2a03bb8a2ba778b56", "outputs": [{"name": "stdout", "output_type": "stream", "text": "0.49999999999999994\n"}]}}, "641a6c1f56804936b1b1bedade7b150a": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "66d3651cf7d348258af6469f1b3ed9f5": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "678ba426d84c4ec7bc3beb019cb56ecc": {"model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": {"layout": "IPY_MODEL_dcfb47f03e3a4038a20e41b06a6708d7", "outputs": [{"ename": "NameError", "evalue": "name 'math' is not defined", "output_type": "error", "traceback": ["\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)", "File \u001b[1;32m~\\miniconda3\\envs\\p2s\\Lib\\site-packages\\ipywidgets\\widgets\\interaction.py:240\u001b[0m, in \u001b[0;36minteractive.update\u001b[1;34m(self, *args)\u001b[0m\n\u001b[0;32m    238\u001b[0m     value \u001b[38;5;241m=\u001b[39m widget\u001b[38;5;241m.\u001b[39mget_interact_value()\n\u001b[0;32m    239\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mkwargs[widget\u001b[38;5;241m.\u001b[39m_kwarg] \u001b[38;5;241m=\u001b[39m value\n\u001b[1;32m--> 240\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mresult \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mf\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    241\u001b[0m show_inline_matplotlib_plots()\n\u001b[0;32m    242\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mauto_display \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mresult \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n", "Cell \u001b[1;32mIn[5], line 2\u001b[0m, in \u001b[0;36mf\u001b[1;34m(x)\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mf\u001b[39m(x):\n\u001b[1;32m----> 2\u001b[0m     a \u001b[38;5;241m=\u001b[39m x\u001b[38;5;241m*\u001b[39m(\u001b[43mmath\u001b[49m\u001b[38;5;241m.\u001b[39mpi\u001b[38;5;241m/\u001b[39m\u001b[38;5;241m180\u001b[39m)\n\u001b[0;32m      3\u001b[0m     \u001b[38;5;28mprint\u001b[39m(math\u001b[38;5;241m.\u001b[39msin(a))\n", "\u001b[1;31mNameError\u001b[0m: name 'math' is not defined"]}]}}, "67c6bb383b644c0b9abc04c9ae4e6a62": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "6b4960d6f772462a9fc60708228db0d9": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "6b716bc3263f47d8a21bb7f2b5c35620": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "6bf3f884e4d74eb586c53fcbe3e9abc9": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "VBoxModel", "state": {"_dom_classes": ["widget-interact"], "children": ["IPY_MODEL_e1cc64874464438abb96fec8a95aa869", "IPY_MODEL_678ba426d84c4ec7bc3beb019cb56ecc"], "layout": "IPY_MODEL_8192b9da66694d8aa5618cc9cda5b773"}}, "6e21045934b347c3811088107f6d68eb": {"model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": {"layout": "IPY_MODEL_641a6c1f56804936b1b1bedade7b150a", "outputs": [{"name": "stdout", "output_type": "stream", "text": "A simple math question: \"10 + 20 = ?\", the answer is 30!\n"}]}}, "7599cb8f58d2491f804cdc405d3b3de0": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "76b8d887ee1a4485a5f518048cc66ef3": {"model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": {"layout": "IPY_MODEL_1029279f289a4c81bcf47c59bc2272c0", "outputs": [{"name": "stdout", "output_type": "stream", "text": "0.49999999999999994\n"}]}}, "7a3f61f49c674aef9cf11ed88bfa5ae0": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "7f27186ea90b4363ba8da4c634fad959": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "81117538a7204835af525956b6952657": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "81485a719b1c4047a55aa4f9469eb9a2": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "8192b9da66694d8aa5618cc9cda5b773": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "81c927ff342f4a4cba245c79187c61e9": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "x", "layout": "IPY_MODEL_9be37d9cc818487e869ab8f8d369f7c7", "max": 30, "min": -10, "style": "IPY_MODEL_ab2a6b587c1d4402b19f4b70e055bddb", "value": 10}}, "81e59674f08446e5b134291b7ae87207": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "85aa9195bd6f402ab20f7999aba1c02f": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "86406453427a4fa48c5dda21b9e532a7": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "87f892e3b1d24f95b46957bfcaef9745": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "8862a778f5204d79881549d3b25222b5": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "889c5c66d5814484beb27a66b0174c0c": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "88bc243b5c4d457f9a88ab47a92adfc0": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "8ef4554089b244a98bd458181b3ba478": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "VBoxModel", "state": {"_dom_classes": ["widget-interact"], "children": ["IPY_MODEL_f3a4cf71e0c546dbbdd3b710356a4015", "IPY_MODEL_44f20e4143974f4a98677aef404da584", "IPY_MODEL_52bc603adc694f558a39258ec1e76156"], "layout": "IPY_MODEL_86406453427a4fa48c5dda21b9e532a7"}}, "9101e470ea6c4347821f91be97ff7e06": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "VBoxModel", "state": {"_dom_classes": ["widget-interact"], "children": ["IPY_MODEL_19b830f2dbd042e49e2cc475f730e733", "IPY_MODEL_2727ceebd04c4d3ab4db4e2dbfc64fa7"], "layout": "IPY_MODEL_213b6906ace74617a0a7c37f7fe80e33"}}, "92c7ee7359014d4e84ab0eb3847896b7": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "943ad1388fb74af699f24bd50ce4e0e2": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "VBoxModel", "state": {"_dom_classes": ["widget-interact"], "children": ["IPY_MODEL_2edda18376d24e9f9a385cbfaede7ffe", "IPY_MODEL_624dfe9850d144ad9468b136f81836ac"], "layout": "IPY_MODEL_60844ca57adf403dbd6b4cd4b8578e15"}}, "993be00b43bf4685ae6fd529f78c437f": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "9be37d9cc818487e869ab8f8d369f7c7": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "9d2b6656488841528dc63d972cb10b07": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "9e1f9f69004e4eb2a03bb8a2ba778b56": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "a2d2a727328940ec907c08a108419005": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "x", "layout": "IPY_MODEL_b565f1d91b3b4939bc9296922d6b4e32", "max": 90, "min": -30, "style": "IPY_MODEL_6b4960d6f772462a9fc60708228db0d9", "value": 30}}, "a540171b24ce4763b108471cb1020a82": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "a84e9e66a9de401783a2a41d817fbc73": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "x", "layout": "IPY_MODEL_7a3f61f49c674aef9cf11ed88bfa5ae0", "max": 30, "min": -10, "style": "IPY_MODEL_66d3651cf7d348258af6469f1b3ed9f5", "value": 10}}, "ab2a6b587c1d4402b19f4b70e055bddb": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "aca0df7dd525439da4fbb3c85ec74a2f": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "b0a8761742ad411994f4968b110a7c5c": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "b14b5a1e63b14da8ac763e094cfbe97d": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "b1c71a66e65c4e539299ff2ed65f20c9": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "b2c1fb0127ed4642ab959be57b91ab27": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "b565f1d91b3b4939bc9296922d6b4e32": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "c1224ebc63a94fc0bf02592c6de76673": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "cf7ece74bf4d47ed8ee83febc744aedb": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "SliderStyleModel", "state": {"description_width": ""}}, "d596c866cd3b4e5b9cca17504c9b5db7": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "VBoxModel", "state": {"_dom_classes": ["widget-interact"], "children": ["IPY_MODEL_a2d2a727328940ec907c08a108419005", "IPY_MODEL_da59898e684a49bca2ded9f82b9de4a7"], "layout": "IPY_MODEL_b1c71a66e65c4e539299ff2ed65f20c9"}}, "da59898e684a49bca2ded9f82b9de4a7": {"model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": {"layout": "IPY_MODEL_08706438180f435da3bb6764b59ab88f", "outputs": [{"ename": "NameError", "evalue": "name 'math' is not defined", "output_type": "error", "traceback": ["\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)", "File \u001b[1;32m~\\miniconda3\\envs\\p2s\\Lib\\site-packages\\ipywidgets\\widgets\\interaction.py:240\u001b[0m, in \u001b[0;36minteractive.update\u001b[1;34m(self, *args)\u001b[0m\n\u001b[0;32m    238\u001b[0m     value \u001b[38;5;241m=\u001b[39m widget\u001b[38;5;241m.\u001b[39mget_interact_value()\n\u001b[0;32m    239\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mkwargs[widget\u001b[38;5;241m.\u001b[39m_kwarg] \u001b[38;5;241m=\u001b[39m value\n\u001b[1;32m--> 240\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mresult \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mf\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    241\u001b[0m show_inline_matplotlib_plots()\n\u001b[0;32m    242\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mauto_display \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mresult \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n", "Cell \u001b[1;32mIn[10], line 2\u001b[0m, in \u001b[0;36mf\u001b[1;34m(x)\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mf\u001b[39m(x):\n\u001b[1;32m----> 2\u001b[0m     a \u001b[38;5;241m=\u001b[39m x\u001b[38;5;241m*\u001b[39m(\u001b[43mmath\u001b[49m\u001b[38;5;241m.\u001b[39mpi\u001b[38;5;241m/\u001b[39m\u001b[38;5;241m180\u001b[39m)\n\u001b[0;32m      3\u001b[0m     \u001b[38;5;28mprint\u001b[39m(math\u001b[38;5;241m.\u001b[39msin(a))\n", "\u001b[1;31mNameError\u001b[0m: name 'math' is not defined"]}]}}, "dcfb47f03e3a4038a20e41b06a6708d7": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "dda5586889234abeb45556613f323c16": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "e1aafd9d805f45ceb2a5a394322f71e4": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "x", "layout": "IPY_MODEL_2b763158a5e74331b3cc64f730e12ada", "max": 90, "min": -30, "style": "IPY_MODEL_cf7ece74bf4d47ed8ee83febc744aedb", "value": 30}}, "e1cc64874464438abb96fec8a95aa869": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "x", "layout": "IPY_MODEL_8862a778f5204d79881549d3b25222b5", "max": 90, "min": -30, "style": "IPY_MODEL_141e098668fe4416ab5cbee6d09464d5", "value": 30}}, "e4ba700850414beeae5cc9e46380bd95": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "VBoxModel", "state": {"_dom_classes": ["widget-interact"], "children": ["IPY_MODEL_e1aafd9d805f45ceb2a5a394322f71e4", "IPY_MODEL_76b8d887ee1a4485a5f518048cc66ef3"], "layout": "IPY_MODEL_523f2d75879a44db95663bb6436dd05d"}}, "e612fa032644456599e7c058fe83441c": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "x", "layout": "IPY_MODEL_b2c1fb0127ed4642ab959be57b91ab27", "max": 30, "min": -10, "style": "IPY_MODEL_67c6bb383b644c0b9abc04c9ae4e6a62", "value": 10}}, "e66005c43b3f46a0b009c97bf618e598": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "e7bc41997974427d8f95d8f330e99fd6": {"model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": {"layout": "IPY_MODEL_0669fc56ae8b408e921beba3520f6d14", "outputs": [{"name": "stdout", "output_type": "stream", "text": "A simple math question: \"10 + 20 = ?\", the answer is 30!\n"}]}}, "e7e8154648c04623b0ddece5ab4c19c4": {"model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": {"layout": "IPY_MODEL_87f892e3b1d24f95b46957bfcaef9745", "outputs": [{"name": "stdout", "output_type": "stream", "text": "A simple math question: \"10 + 20 = ?\", the answer is 30!\n"}]}}, "f2870f8d10d34b3f96d42559e9daa2bb": {"model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {}}, "f3a4cf71e0c546dbbdd3b710356a4015": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "x", "layout": "IPY_MODEL_dda5586889234abeb45556613f323c16", "max": 30, "min": -10, "style": "IPY_MODEL_30c6c6a8026a475fa022433c08b69516", "value": 10}}, "f547b163776f400f88246dd3034af06d": {"model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "IntSliderModel", "state": {"behavior": "drag-tap", "description": "x", "layout": "IPY_MODEL_9d2b6656488841528dc63d972cb10b07", "max": 90, "min": -30, "style": "IPY_MODEL_81485a719b1c4047a55aa4f9469eb9a2", "value": 30}}}, "version_major": 2, "version_minor": 0}</script>
    <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
    <script crossorigin="anonymous" data-jupyter-widgets-cdn="https://cdn.jsdelivr.net/npm/" src="https://cdn.jsdelivr.net/npm/@jupyter-widgets/html-manager@1.0.6/dist/embed-amd.js"></script>
    </body>
</html>